// pages/doctor-field-level/doctor-field-level.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    listData:[],
    cityRankId:'',
    data:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.setData({
      data: JSON.parse(options.data),
      cityRankId: options.cityRankId
    })
    this.getCityRankList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  // 选择级别
  radioChange(e) {
    const cityRankId = e.currentTarget.dataset.id;
    this.setData({
      cityRankId 
    })
  },


  // 获取场地列表
  getCityRankList(){
    const that= this;
    const param = {
      areaId :2
    };
    app.request({
      url: "doctor/demandApi/getCityRankList",
      data: param,
      success: function (res) {
        that.setData({
          listData: res.data
        })
      },
      fail: function (res) {
        // app.requestFail(res);
      }
    });
  },
  // 下一步
  next(){
    const cityRankId = this.data.cityRankId;
    if (!app.validate(cityRankId, 'required')) {
      app.showModal('请选择场地级别');
      return;
    }
    const { chooseReason, demandId, mainId, mainPrice, relationInfos, mainPriceId} = this.data.data;
    const data = {
      cityRankId,
      mainPriceId,
      chooseReason, 
      demandId,
      mainId,
      mainPrice, 
      relationInfos
    }
    wx.navigateTo({
      url: '/pages/doctor-anesthesia-mode/doctor-anesthesia-mode?data=' + JSON.stringify(data)
    });
  }
})